<style type="text/css">
    .err_msg{
        display: none;
        font-weight: bold;
        font-style: italic
    }
</style>

<script typ="text/javascript">
    $(document).ready(function(){
        var flag = true;
        $('#regBtn').click(function(){
            var fname = $('#fname').val();
            var lname = $('#lname').val();
            var email = $('#email').val();
            var pass = $('#password').val();
            var cpass = $('#cpassword').val();
            
            $('#fname_error').hide();
            $('#lname_error').hide();
            $('#email_error').hide();
            $('#pass_error').hide();
            $('#cpass_error').hide();
            
            if(fname == null || fname == ''){
                $('#fname_error').show();
                $('#fname_error').html('First name required');
                flag = false;
            }
            if(lname == null || lname == ''){
                $('#lname_error').show();
                $('#lname_error').html('Last name required');
                flag = false;
            }
            if(email == null || email == ''){
                $('#email_error').show();
                $('#email_error').html('Email required');
                flag = false;
            }else if(!checkEmail(email)){
                $('#email_error').show();
                $('#email_error').html('Valid email required');
                flag = false;
            }
            
            if(pass == null || pass == ''){
                $('#password_error').show();
                $('#password_error').html('Password required');
                flag = false;
            }
            if(cpass == null || cpass == ''){
                $('#cpassword_error').show();
                $('#cpassword_error').html("Confirm password required");
                flag = false;
            }else if(pass !== cpass){
                $('#cpassword_error').show();
                $('#cpassword_error').html("Password doesn't match");
                flag = false;
            }
            
            return flag;
        });
        
        $('#loginBtn').click(function(){
            var flag = true;
            var email = $('#UserEmail').val();
            var pass = $('#Password').val();
            $('#UserEmail_error').hide();
            $('#Password_error').hide();
            if(email == null || email == ''){
                $('#UserEmail_error').show();
                $('#UserEmail_error').html('Email required');
                flag = false;
            }
            if(pass == null || pass == ''){
                $('#Password_error').show();
                $('#Password_error').html('Password required');
                flag = false;
            }
            return flag;
        });
        
        $('#forgotBtn').click(function(){
            var flag = true;
            var email = $('#ForgotUserEmail').val();
            $('#ForgotUserEmail_error').hide();
            if(email == null || email == ''){
                $('#ForgotUserEmail_error').show();
                $('#ForgotUserEmail_error').html('Email required');
                flag = false;
            }else if(!checkEmail(email)){
                $('#ForgotUserEmail_error').show();
                $('#ForgotUserEmail_error').html('Valid email required');
                flag = false;
            }
            return flag;
        });
        
    });
    
    function checkEmail(inputvalue){	
        var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
        if(pattern.test(inputvalue)){         
                return true;   
        }else{   
                return false; 
        }
    }
    
</script>
<h1>To create will, Login Here</h1>
<div id="form_wrapper" class="clearfix">
    <div class="left login-left" style="">
        <h2>Already Registered ? Login here !</h2>
            <form name="loginform" id="loginform" action="/main/account/login" method="post">
                <div class="clearfix column_wrapp">
                    <div class="frm_row">
                        <?php echo $this->loginForm->UserEmail->render()?>
                        <span class="err_msg" id="UserEmail_error"></span>
                        <!--
                        <label for="name">Email Address *</label>
                        <input type="text" class="frmInput" id="name" name="name" />
                        -->
                    </div>
                    <div class="frm_row">
                        <?php echo $this->loginForm->Password->render()?>
                        <span class="err_msg" id="Password_error"></span>
                    </div>
                    <div class="frm_row">
                        <input type="submit" class="submitBtn" id="loginBtn" value="Login" />
                    </div>
                </div>
            </form>
	</div>

    <?php
            $ermsg = $this->loginForm->getMessages();
            $err_html = '';
            if(isset($ermsg['UserEmail']['stringLengthTooShort']))
            {
                $err_html .= ' - Username '.$ermsg['UserEmail']['stringLengthTooShort'] .' <br>';
            }
            if(isset($ermsg['Password']['stringLengthTooShort']))
            {
                $err_html .= ' - Password '. $ermsg['Password']['stringLengthTooShort'] .'<br>';
            }
            if(isset($ermsg[0]['Invalid']))
            {
                $err_html .= 'Wrong username or password<br>';
            }
        ?>

        <?php if(isset($ermsg['UserEmail']) || isset($ermsg['Password'] ) || isset($ermsg[0]['Invalid']) ):?>
                <div class="login_message message error">
                  <?php echo ' <p>', $err_html, '</p>'?>
                </div>
       <?php endif;?>

        <div class="left login-right">
            
            <?php 
            $flashMessenger = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
            $msg = $flashMessenger->getMessages();
            
            if(isset($msg) && count($msg) > 0){?>
                <span style="font-weight: bold">
                    <?php echo $msg[1]; ?>
                    <br/>
                </span>
            <?php } ?>
            <h2>Register here !</h2>
            <form name="registerform" id="registerform" action="/main/account/register" method="post">
                <div class="clearfix column_wrapp">
                    <div class="frm_row">
                        <label for="emfnameail">First Name*</label>
                        <input type="text" class="frmInput" id="fname" name="fname"/>
                        <span class="err_msg" id="fname_error"></span>
                    </div>

                    <div class="frm_row">
                        <label for="lname">Last Name *</label>
                        <input type="text" class="frmInput" id="lname" name="lname" />
                        <span class="err_msg" id="lname_error"></span>
                    </div>

                    <div class="frm_row">
                        <label for="email">Email Address *</label>
                        <input type="text" class="frmInput" id="email" name="email" />
                        <span class="err_msg" id="email_error"></span>
                    </div>
                    <div class="frm_row">
                        <label for="password">Password *</label>
                        <input type="password" class="frmInput" id="password" name="password" />
                        <span class="err_msg" id="password_error"></span>
                    </div>

                    <div class="frm_row">
                        <label for="cpassword">Confirm Password *</label>
                        <input type="password" class="frmInput" id="cpassword" name="cpassword" />
                        <span class="err_msg" id="cpassword_error"></span>
                    </div>

                    <div class="frm_row">
                        <label for="gender">Gender *</label>
                        <select name="gender">
                            <option value="1">Male</option>
                            <option value="2">Female</option>
                        </select>
                        
                    </div>
                    <div class="frm_row">
                        <input type="submit" id="regBtn" class="submitBtn" value="Register" />
                    </div>
                </div>
            </form>
        </div>
</div>

<div class="login-left" style="padding-top:20px">
    <?php if(isset($msg[1]) && count($msg[1]) > 0){?>
                <span style="font-weight: bold">
                    <?php echo $msg[1][0]; ?>
                    <br/>
                </span>
            <?php } ?>
    <h2>Forgot Password!</h2>
        <form name="forgotform" id="forgotform" action="/main/account/forgot" method="post">
			<div class="clearfix column_wrapp">
                            <div class="form_column_l">
                                <div class="frm_row">
                                    <?php //echo $this->loginForm->UserEmail->render()?>
                                    <input type="text" class="frmInput" id="ForgotUserEmail" name="ForgotUserEmail" />
                                    <span class="err_msg" id="ForgotUserEmail_error"></span>
                                </div>
                                <div class="frm_row">
                                    <input type="submit" class="submitBtn" id="forgotBtn" value="Get Password" />
                                </div>
                            </div>
			</div>
		</form>
</div>